// /////////////////////////////////////////////////////////////////////////////
//
// Name:            asLightComponent.cpp
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Binds the LightComponent class to AngelScript
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

// Include files
#include "asLightComponent.h"

#ifdef __COMPILE_WITH_ANGELSCRIPT__

#include "../../ScriptHelper.h"
#include "asSceneComponent.h"

#include "../../../components/scene/LightComponent.h"


//! Reference factory for the LightComponent class.
LightComponent* createLightComponent(Entity *parent)
{
    return new LightComponent(parent);
}

//! Reference factory for the LightComponent class.
LightComponent* createLightComponent(Entity *parent, const SColor &color, f32 radius)
{
    return new LightComponent(parent, color, radius);
}

//! Binds the LightComponent class to AngelScript.
void bindLightComponent(asIScriptEngine *engine)
{
    // Forward declarations.
    int r;

    // Bind LightComponent class.
    r = engine->RegisterObjectType("LightComponent", sizeof(LightComponent), asOBJ_REF); assert(r >= 0);

    // Bind inherited functions.
    bindSceneComponentBase<LightComponent>(engine, "LightComponent");

    // Set LightComponent behaviour.
    r = engine->RegisterObjectBehaviour("LightComponent", asBEHAVE_FACTORY, "LightComponent@ f(Entity @+)",
                                        asFUNCTIONPR(createLightComponent, (Entity*), LightComponent*),
                                        asCALL_CDECL); assert(r >= 0);
    r = engine->RegisterObjectBehaviour("LightComponent", asBEHAVE_FACTORY, "LightComponent@ f(Entity @+, " \
                                        "const SColor&in, f32)",asFUNCTIONPR(createLightComponent,
                                        (Entity*, const SColor &color, f32), LightComponent*), asCALL_CDECL);
                                        assert(r >= 0);

    r = engine->RegisterObjectMethod("LightComponent", "LightComponent& opAssign(const LightComponent &in)",
                                     asFUNCTION(assignT<LightComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0);

    // Bind LightComponent class functions.
    r = engine->RegisterObjectMethod("LightComponent", "bool getCastShadow()",
                                     asMETHOD(LightComponent, getCastShadow), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("LightComponent", "E_LIGHT_TYPE getLightType()",
                                     asMETHOD(LightComponent, getLightType), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("LightComponent", "f32 getRadius()",
                                     asMETHOD(LightComponent, getRadius), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("LightComponent", "void setCastShadow(bool)",
                                     asMETHOD(LightComponent, setCastShadow), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("LightComponent", "void setLightType(E_LIGHT_TYPE)",
                                     asMETHOD(LightComponent, setLightType), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("LightComponent", "void setRadius(f32)",
                                     asMETHOD(LightComponent, setRadius), asCALL_THISCALL); assert(r >= 0);
}

#endif // __COMPILE_WITH_ANGELSCRIPT__

// End of File
